import { IToolTipItem } from "../../../../com/mui/manager/IToolTipItem";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
import { Cache } from "../../cache/Cache";
import { Language } from "../../../../extend/language/Language";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class FightSpiritBtn
    
    export  class FightSpiritBtn /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor()
        {
            
            this.initView();
            this.buttonMode = true;
            this.useHandCursor = true;
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onClickHandler);
            return;
        }

        public get mode(): string
        {
            return this._mode;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            return;
        }

        /* internal  */initView(): void
        {
            this._btn = ObjCreate.createGLoadedButton(ResFileConst.FightSpiritBtn, 0, 0, 32, 29, this);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            return;
        }

        /* internal  */onClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.mode == GModuleEvent.Mode_Self) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.FightSpiritShowModule));
            }
            return;
        }

        public get toolTipData()
        {
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._toolTipData = arg1;
            return;
        }

        public updateTips(arg1: Array<any>, arg2: int, arg3: int): void
        {
            var loc1=null;
            var loc4=0;
            var loc5=0;
            var loc7=0;
            var loc2=Cache.instance.fightSpirit.getCurAddPrecentShow(arg2, arg3);
            var loc3=Language.getString(71116) + "  Lv." + arg2 + "<br>" + Language.getStringByParam(71122, loc2 / 100) + Language.getString(71121);
            var loc6=0;
            while (loc6 < arg1.length) 
            {
                loc1 = arg1[loc6];
                loc4 = 0;
                loc5 = 0;
                loc7 = 0;
                while (loc7 < loc1.value.length) 
                {
                    loc4 = loc4 + loc1.value[loc7];
                    loc5 = loc5 + Math.floor(loc1.value[loc7] * loc2 / 10000);
                    ++loc7;
                }
                loc3 = loc3 + ("<font color=\'#B1efff\'>  " + loc1.name + "： " + loc4 + "</font>" + " + " + "<font color=\'#00ff00\'>" + loc5 + "</font>" + "<br>");
                ++loc6;
            }
            loc3 = loc3 + Language.getString(71123);
            this.toolTipData = "<textFormat leading=\'3\'>" + HTMLUtil.addColor(loc3, "#FFFFFF") + "</textFormat>";
            return;
        }

        /* internal */ /* var */_btn: GLoadedButton;

        /* internal */ /* var */_btnBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_mode: string="自己";

        protected /* var */_toolTipData;
    }
